nmcli 是 NetworkManager 的命令行接口,可以用来管理网络连接、设备和活动。以下是一些常用的 nmcli 命令示例:

1、查看所有连接:

nmcli con show

2、查看所有设备状态:

nmcli dev status

3、启用Wi-Fi:

nmcli radio wifi on

4、扫描可用的Wi-Fi网络:

nmcli dev wifi list

5、连接到Wi-Fi网络:

nmcli con up id "Your Wi-Fi Network Name" password "your-password"

6、断开Wi-Fi连接:

nmcli con down id "Your Wi-Fi Network Name"

7、添加一个新的有线(以太网)连接:

nmcli con add type ethernet con-name "My Ethernet" ifname eth0

8、添加一个新的Wi-Fi连接:

nmcli con add type wifi con-name "My Wi-Fi" ifname wlan0 ssid "your-ssid"

9、删除一个连接:

nmcli con delete id "Connection Name"

10、修改一个连接的设置:

nmcli con modify "Connection Name" ipv4.addresses "192.168.1.100/24"

11、启用或禁用网络连接

$ nmcli connection up <connection-name>
$ nmcli connection down <connection-name>

12、添加一个新的网络连接

$ nmcli connection add type ethernet ifname eth0 con-name MyConnection

13、修改网络连接的配置

$ nmcli connection modify <connection-name> <setting> <value>

14、将静态 IP 地址分配给一个有线连接:

nmcli connection modify MyConnection ipv4.addresses 192.168.1.100/24
nmcli connection modify MyConnection ipv4.gateway 192.168.1.1
nmcli connection modify MyConnection ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify MyConnection ipv4.method manual

请根据实际情况替换 "Your Wi-Fi Network Name", "your-password", "your-ssid", "My Ethernet", "My Wi-Fi", "Connection Name" 等参数。

Copyright © https://yan-jian.com 2023 all right reserved更新时间: 2024-11-06 16:22:42

results matching ""

    No results matching ""